#-*- coding = utf-8 -*-
#@Time : 2021/10/8 18:11
#@Author : 08A
#@File : MiniDuckSimulator.py
#@Software : PyCharm
class FlyBehavior(object):
    def fly(self):
        raise NotImplementedError()

class FlyWithWings(FlyBehavior):
    def fly(self):
        print("I'm flying!!")

class FlyNoWay(FlyBehavior):
    def fly(self):
        print("I can't fly")

class FlyRocketPowered(FlyBehavior):
    def fly(self):
        print("I'm flying with a rocket")

class QuackBehavior(object):
    def quack(self):
        raise NotImplementedError()

class Squeak(QuackBehavior):
    def quack(self):
        print("Squeak")


class Quack(QuackBehavior):
    def quack(self):
        print("Quack")

class MuteQuack(QuackBehavior):
    def quack(self):
        print("<< Silence >>")

class FakeQuack(QuackBehavior):
    def quack(self):
        print("Qwak")



class Duck(object):

    def setFlyBehavior(self,fly_duck):
        self.fly_duck=fly_duck

    def setQuackBehavior(self,quack_duck):
        self.quack_duck=quack_duck

    def performFly(self):
        self.fly_duck.fly()

    def performQuack(self):
        self.quack_duck.quack()

    def swim(self):
        print("All ducks float, even decoys!")


class DecoyDuck(Duck):

    def __init__(self):
        self.setFlyBehavior(FlyNoWay())
        self.setQuackBehavior(MuteQuack())

    def display(self):
        print("I'm a duck Decoy")

class MallardDuck(Duck):
    def __init__(self):
        self.setFlyBehavior(FlyWithWings())
        self.setQuackBehavior(Quack())

    def display(self):
        print("I'm a real Mallard duck")


class ModelDuck(Duck):
    def __init__(self):
        self.setFlyBehavior(FlyNoWay())
        self.setQuackBehavior(Quack())

    def display(self):
        print("I'm a real model duck")

class RedHeadDuck(Duck):
    def __init__(self):
        self.setFlyBehavior(FlyWithWings())
        self.setQuackBehavior(Quack())

    def display(self):
        print("I'm a real Red Headed duck")


class RubberDuck(Duck):
    def __init__(self):
        self.setFlyBehavior(FlyNoWay())
        self.setQuackBehavior(Squeak())


    def display(self):
        print("I'm a rubber duckie")

if __name__ == '__main__':
    mallard = MallardDuck()
    rubberDuckie = RubberDuck()
    decoy = DecoyDuck()
    model = ModelDuck()

    mallard.performQuack()
    rubberDuckie.performQuack()
    decoy.performQuack()

    model.performFly()
    model.setFlyBehavior(FlyRocketPowered())
    model.performFly()

